#ifndef GRAPHICS_IMAGE2D_H
#define GRAPHICS_IMAGE2D_H

#include <core/core.h>

namespace yam3d
{
namespace graphics
{

    class Image2D
    {
    public:
        Image2D( const char* const filename, bool convertToRGBA = true );
        Image2D( int w, int h, bool convertToRGBA = true );
        ~Image2D();

        int width() const;
        int height() const;
        int getFormat() const;

        core::byte* getPixel( int x, int y );

        Image2D* genMipMap2D();

    private:
        bool m_convertToRGBA;

        void load( const QString& filename );

        void createBuf( int w, int h )
        {
                m_w = w;
                m_h = h;
                if( m_convertToRGBA )
                {
                    m_buf.resize( m_w*m_h*4 );
                    memset(&m_buf[0], 0xffffffff, m_w*m_h*4 );
                }
                else
                {
                    m_buf.resize( m_w*m_h*3 );
                    memset(&m_buf[0], 0xffffffff, m_w*m_h*3 );
                }
        }


        core::ByteVector m_buf;
        int m_w;
        int m_h;

        Image2D( bool convertToRGBA = true );
        Image2D(const Image2D&);
        Image2D& operator=(const Image2D&);
    };



}
}

#endif // GRAPHICS_IMAGE2D_H





